<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>企业管理-后台管理系统</title>
<link rel="stylesheet"
	href="${rc.contextPath}/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" href="${rc.contextPath}/zui/css/zui.css" />
<script src="${rc.contextPath}/js/jquery.1.10.1.min.js"></script>
<script type="text/javascript" src="${rc.contextPath}/js/jquery.lib.min.js"></script>
<script type="text/javascript" src="${rc.contextPath}/zui/js/zui.js"></script>
</head>
<body>

		<ul class="nav nav-tabs" id="adminTab">
			<li>
				<a href="index.html" data-togggle="tab">首页</a>
			</li>
			<li class="active">
				<a href="${rc.contextPath}/admin/erterprise_manage" data-togggle="tab">企业管理及审核</a>
			</li>
			<li>
				<a href="forum_manage.html" data-togggle="tab">论坛管理</a>
			</li>
			<li>
				<a href="message.html" data-togggle="tab">消息</a>
			</li>
			<li class="pull-right">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown">
					<img src="${rc.contextPath}/img/leader_default.png" width="20px" />管理员<span class="caret"></span>
				</a>
				<ul class="dropdown-menu">
					<li>
						<a href="#">账号设置</a>
					</li>
					<li>
						<a href="#">退出</a>
					</li>
				</ul>
			</li>
		</ul>

		<!--  左侧菜单  -->
		<div style="margin-top: 20px;" class="col-xs-2">
			<nav class="menu" data-toggle="menu" style="width: 200px;">
				<ul class="nav nav-primary">

					<li class="active show nav-parent">
						<a href="javascript:;"><i class="icon icon-group"></i> 公司</a>
						<ul class="nav">
							<li>
								<a href="enterprise_manage.html"><i class="icon icon-cog"></i> 公司信息管理</a>
							</li>
							<li>
								<a href="enterprise_check.html">
									<i class="icon icon-trophy"></i> 公司认证审核<span class="label label-badge pull-right">5</span>
								</a>
							</li>
							<li class="active">
								<a href="javascript:;" th:href="@{/user/toBlogtypeManager}"><i class="icon icon-plus"></i> 添加公司</a>
							</li>
						</ul>
					</li>

					<li class="active show nav-parent">
						<a href="javascript:;"><i class="icon icon-book"></i> 招聘</a>
						<ul class="nav">
							<li>
								<a href="job_manage.html"><i class="icon icon-list-ul"></i> 招聘管理</a>
							</li>
							<li>
								<a href="javascript:;"><i class="icon icon-pencil"></i> 发布招聘</a>
							</li>
						</ul>
					</li>
				</ul>
			</nav>
		</div>
		
		<div class="col-xs-8" style="margin-top: 20px;">
			<form id="addcompanyForm" class="form-horizontal" action="#">
				<div class="panel">
					<div class="panel-header">
						<h4 class="panel-title">修改公司信息</h4>
					</div>
					<div class="panel-body">
						
							<div class="form-group">
								<label for="company_logo_upload" class="col-sm-2">公司logo</label>
								<div class="col-md-6 col-sm-10">
									<img class="img-thumbnail" name="show_company_logo" id="show_company_logo" width="50px" 
										src="${rc.contextPath}/img/logo_default.png"/>
									<input type="hidden" name="company.company_logo" id="company_logo" />
									<input type="file" class="form-control" id="company_logo_upload" 
										name="company_logo_upload" onchange="ajaxfileuploadCompanyLogo()">
								</div>
							</div>
							<div class="form-group">
								<label for="company_name" class="col-sm-2">公司全称</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="company.company_name" name="company.company_name" placeholder="公司全称">
								</div>
							</div>
							<div class="form-group">
								<label for="company_website" class="col-sm-2">公司网址</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="company.company_website" name="company.company_website" placeholder="公司网址">
								</div>
							</div>
							<div class="form-group">
								<label for="company_location" class="col-sm-2">公司所在城市</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="company.company_location" name="company.company_location" placeholder="公司所在城市">
								</div>
							</div>
							<div class="form-group">
								<label for="company_address" class="col-sm-2">公司具体地址</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="company.company_address" name="company.company_address" placeholder="公司具体地址">
								</div>
							</div>
							<div class="form-group">
								<label for="company_domain" class="col-sm-2">行业领域</label>
								<div class="col-md-6 col-sm-10">
									<select class="form-control" id="company.company_domain" name="company.company_domain">
									#foreach($!domain in $!domainList)
										<option value="$!domain.id">$!domain.domain_name</option>
									#end
									</select>
								</div>
							</div>
							<div class="form-group">
								<label for="company_scale" class="col-sm-2">公司规模</label>
								<div class="col-md-6 col-sm-10">
									<select class="form-control" id="company.company_scale" name="company.company_scale">
										<option value="0">少于15人</option>
										<option value="1">15-50人</option>
										<option value="2">50-150人</option>
										<option value="3">150-500人</option>
										<option value="4">500-2000人</option>
										<option value="5">2000人以上</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label for="company_develop" class="col-sm-2">发展阶段</label>
								<div class="col-md-6 col-sm-10">
									<select class="form-control" id="company.company_develop" name="company.company_develop"> 
										<option value="0"><span>未融资</span></option>
										<option value="1"><span>天使轮</span></option>
										<option value="2"><span>A轮</span></option>
										<option value="3"><span>B轮</span></option>
										<option value="4"><span>C轮</span></option>
										<option value="5"><span>D轮以上</span></option>
										<option value="6"><span>上市公司</span></option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label for="company_brief" class="col-sm-2">一句话简介</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="company.company_brief" name="company.company_brief" placeholder="简介">
								</div>
							</div>
							<div class="form-group">
								<label for="company_detail" class="col-sm-2">详细介绍</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" placeholder="请分段详细描述公司简介、企业文化等" name="companyDetail.detail_content" id="companyDetail.detail_content"/>	
								</div>
							</div>
							<div class="form-group">
								<label for="product_image_upload" class="col-sm-2">产品海报</label>
								<div class="col-md-6 col-sm-10">
									<img class="img-thumbnail" name="show_product_image" id="show_product_image" width="50px"
										src="${rc.contextPath}/img/product_default.png"/>
									<input type="hidden" name="product.product_image" id="product_image"/>
									<input type="file" class="form-control" id="product_image_upload" name="product_image_upload"
										onchange="ajaxfileuploadProductImage()">
								</div>
							</div>
							<div class="form-group">
								<label for="product_name" class="col-sm-2">产品名称</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="product.product_name" name="product.product_name" placeholder="产品名称">
								</div>
							</div>
							<div class="form-group">
								<label for="product_url" class="col-sm-2">产品链接</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="product.product_url" name="product.product_url" placeholder="产品链接">
								</div>
							</div>
							<div class="form-group">
								<label for="product_brief" class="col-sm-2">产品简介</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="product.product_brief" name="product.product_brief" placeholder="产品简介">
								</div>
							</div>
						
					</div>

					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						<button type="button" class="btn btn-primary" id="tijiao">保存</button>
					</div>
				</div>
				</form>
		</div>

</body>
	<script type="text/javascript" src="${rc.contextPath}/js/upload/ajaxfileupload.js"></script>
	<script type="text/javascript">
	$("#tijiao").click(function(){
		jQuery.post("${rc.contextPath}/admin/addnewcompany", $("#addcompanyForm").serialize(), function(data) {
			/* if(data.code == 200){ */
				(new jQuery.zui.ModalTrigger({
					custom : data.info
				})).show({hidden: function(){
					if(data.code == 200){
						window.location.href = "${rc.contextPath}/admin/addcompany";
					}
				}});
				/* window.location.href = "${rc.contextPath}/admin/addcompany"; */
			//}
		}, 'json');
	});
			$(function() {
				
					
				//验证表单
				/* $("#addcompanyForm").validate({
					rules: {
						company_name: {
							required: true,
						},
						company_address: {
							required: true
						},
						company_brief: {
							required: true
						},
						company_detail: {
							required: true
						},
						product_name: {
							required: true
						},
						product_brief: {
							required: true
						}
					},
					messages: {
						company_name: {
							required: "请输入公司名称"
						},
						company_address: {
							required: "请输入公司具体地址"
						},
						company_brief: {
							required: "请输入公司简介"
						},
						company_detail: {
							required: "请输入公司详情"
						},
						product_name: {
							required: "请输入产品名称，如没有，请输入无"
						},
						product_brief: {
							required: "请输入产品简介"
						}
						
					},
					submitHandler: function(form) {


						$(form).find(":submit").attr("disabled", true);
						
						/* jQuery.post("${rc.contextPath}/admin/addnewcompany", $("#addcompanyForm").serialize(), function(data) {
							if(data.code == 200){
								(new jQuery.zui.ModalTrigger({
									custom : "添加成功"
								})).show();
								window.location.href = "${rc.contextPath}/admin/addcompany";
							}
							(new jQuery.zui.ModalTrigger({
								custom : data.info
							})).show();
							
						}, 'json');
						
					} 
				}); */
			});
			
			function ajaxfileuploadCompanyLogo(){
				jQuery.ajaxFileUpload(
					{
						type:'post',
						url:"${rc.contextPath}/admin/uploadImage/0",
						secureuri:false,
						fileElementId:"company_logo_upload",
						/* dataType:"json", */
						success:function(data,status){
							var str = $(data).find("body").text();
							var json = jQuery.parseJSON(str);
							if(json.code==800){
								(new jQuery.zui.ModalTrigger({
									custom : "上传成功"
								})).show();
								$("#company_logo").val(json.info);
								$("#show_company_logo").attr("src","http://127.0.0.1:8080/image/companylogo/"+json.info);  
							}else{
								(new jQuery.zui.ModalTrigger({
									custom : json.code+json.info
								})).show();
							}
							//alert(data.info);
						},
						error:function(data,status,e){
							(new jQuery.zui.ModalTrigger({
								custom : data.code+data.info
							})).show();
						}
					}					
				)
			}
			function ajaxfileuploadProductImage(){
				jQuery.ajaxFileUpload(
					{
						url:"${rc.contextPath}/admin/uploadImage/1",
						secureuri:false,
						fileElementId:"product_image_upload",
						/* dataType:"json", */
						success:function(data,status){
							var str = $(data).find("body").text();
							var json = jQuery.parseJSON(str);
							if(json.code==800){
								
								$("#product_image").val(json.info);
								$("#show_product_image").attr("src","http://127.0.0.1:8080/image/productimage/"+json.info);  
							}else{
								(new jQuery.zui.ModalTrigger({
									custom : json.code+json.info
								})).show();
							}
							//alert(data.info);
						},
						error:function(data,status,e){
							(new jQuery.zui.ModalTrigger({
								custom : data.code+data.info
							})).show();
						}
					}					
				)
			}
		</script>
</html>